import { defineStore } from 'pinia';

export const useCountStore = defineStore('count', {
    actions: {
        // 此处的this指向pinia实例,可以打印查看
      add(value:number){
        // console.log(this)
        this.sum += value
      },
      nextStudent(){
        this.name = 'hkk'
        this.age = 24
        this.sex = '女生'
      }
    },
    state(){
        return{
            sum : 0,
            name:'maimai',
            age:18,
            sex:'男生'
        }
    },
    getters:{
        // getter 的两种写法 这里也能接收到this
        bigname: (state) => state.name.toUpperCase(),
        bigage():number{return this.age + 2},

    }
})